package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.esm.model.User;
import com.esm.service.GetMyCallMsgService;
import com.esm.serviceimpl.GetMyCallMsgServiceImpl;

import net.sf.json.JSONArray;
/**
 * 
 * @author zyj
 *
 */
public class GetMyCallMsgController extends HttpServlet{
	GetMyCallMsgService gs=new GetMyCallMsgServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		HttpSession session=req.getSession();
		User curUser=(User) session.getAttribute("currentUser");
		int uid=curUser.getUid();
		JSONArray myCallMsg=gs.getMyCallMsg(uid);
		PrintWriter pw=resp.getWriter();
		pw.write(myCallMsg.toString());
		pw.flush();
		pw.close();
	}
}
